Repository navigation
fix(studio): a sealed gesture recording moves the layer live in the preview - #8592
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 48 of thoseThe gate passes. Quarantined, measured but not gated (0) |
|
#8591 is on main, merged in at 96f0a7f so the edit accuracy gate reruns on it. On the non-blocking jump (a recording started while an earlier sealed drag on the layer is still saving): the follow-up that moves the recording onto the frame's GSAP route sets absolute values instead of a translate over the frame's before-record, which is where that jump comes from. I'll cover it with a row there. |
jrusso1020
left a comment
There was a problem hiding this comment.
Verdict: APPROVE. Need ✅ · Size ✅ (+13 product lines) · Reuse ✅ (drawPreviewDraft/endPreviewDraft, the same draft a sealed drag draws) · Simpler ✅ · Structure ✅
Risk: low. Only sealed recordings take the new path, and unsealed draws nothing (pinned by the second test).
What I checked at 670a0f6c; 96f0a7fe only merges main (with #8591), and its diff against main has the same changed lines:
- Fails without the fix. The named test reads
drafts.draw.mock.lastCall. Before this change the recorder never draws a draft, so that read fails and the test goes red. With the fix it pins the offset (+200 px) and a single"restore"end. - Units. The draft draws
x/y − basePosition, which is the same offset from the recording start that gets recorded. A sealed drag passes the same kind of value (offset − initialOffset), so the preview and the saved keyframes agree. - Every exit ends the draft.
releaseRuntimePreviewends the draft before its!runtimeearly return, and on a sealed frame that early return always fires.stopRecordingand unmount both go through it. AstartRecordingthat fails returns beforedrawsOnis set, so nothing is left to clean up. - Rotate and size.
drawPreviewDraftmerges each new part into the earlier ones, so drawing onlytranslatekeeps any rotate or size already drawn on that stand-in.
Non-blocking: if a recording starts while an earlier sealed drag on the same layer is still saving, the recording's first draw takes over that draft and clears the saving mark. Its "restore" then puts the layer back to its place before the drag until the save's reload lands. The layer can briefly jump during that window, but nothing saved changes. A follow-up could start the recording only after previewDraftLive is false.
— Rames (hf-review)
What
On a sealed preview, recording a gesture now shows the layer moving with the pointer while you record, as it does unsealed. Before, the layer stood still in the preview until the recording was saved.
Why
Unsealed, the recorder moves the layer live by setting its GSAP values through the frame's window on every sample. A sealed frame doesn't expose its window, so the recorder recorded the right values (#8568) but drew nothing while recording.
Related work
Follows #8568, which made a sealed recording read the layer's values and the film's size from the frame.
How
useGestureRecording.ts: on a sealed frame, each sample that moves the layer draws its offset from where the recording started on the layer's stand-in, throughdrawPreviewDraft, the same draft a sealed drag draws. When the recording stops or Studio unmounts, the draft ends with "restore", so the layer goes back as unsealed'sclearPropsputs it back until the saved keyframes load. Unsealed is unchanged.Limits: the draft draws position only, so a sealed recording shows a move live but not a scale, opacity or rotation change. A layer whose position GSAP already animates shows that animation plus the recorded offset while recording; the saved keyframes are unaffected.
Before
Sealed preview, mid-recording after moving the pointer down and right: the layer (yellow) stays where it started.
After
Same recording: the layer follows the pointer. Its box at this moment, read from the frame, is the same as unsealed's to the pixel (1264, 596 in film px from 600, 330 at the start).
Test plan
fails without the fix:
packages/studio/src/hooks/useGestureRecording.sealed.test.tsx: "draws the layer moving live on the frame, and puts it back when the recording stops"."draws nothing over the channel for an unsealed frame, whose GSAP moves the layer" (same file) passes on main too; it pins that unsealed draws nothing.
useGestureRecording.sealed.test.tsx,useGestureRecording.test.tsanduseGestureCommit.test.tsxpass three runs in a row on Linux (30 tests). Studio'ssrc/hooks(178 files, 1,864 tests) passes, and Studio typechecks clean.move-idlecase (GSAP loaded, no tween), sealed and unsealed.